package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.CheckInView;

import java.util.List;
import java.util.Map;

/**签到
 * Created by admin on 2018/1/16.
 */

public class CheckInPest {
    private CheckInView commentView;
    public CheckInPest(CheckInView commentView) {
        this.commentView = commentView;
    }

    public void setCheckIn(Context context) {
        Map<String,Object> map= HeadParamBean.getHead(context);
        new ApiManager().setCheckIn(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                commentView.setCheckInSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                commentView.showError("签到失败");
            }
        });
    }

    public void getCheckIn(Context context,int year,int month) {
        Map<String,Object> map= HeadParamBean.getHead(context);
        if (year > 0 && month > 0){
            map.put("year",year);
            map.put("month",month);
        }
        new ApiManager().getCheckIn(map, new BaseCallBack<BaseResult<List<String>>>() {
            @Override
            public void onSuccess(BaseResult<List<String>> response) {
                commentView.getCheckInListSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                commentView.showError(message);
            }
        });
    }
}
